--Hold information about the game/user
game = {}
--Setup basic game info
--Allow fullscreen, width, height, vysnc, anti-aliasing, max supported resolution
function game:setup(allowF,w,h,v,a, maxW, maxH)
  --Vsync enabled?
  game.vsync = v or true
  --Full-scene anti-aliasing amount
  game.aa = a or 0
  --Windowed size and screen scale.
  game.window = { width = w, height = h, scale = {x = w/(maxW or w), y = h/(maxH or h)} }
  --Is fullscreen allowed and set it to currently be off
  game.fullscreen = {allowed = allowF or false, state = false}
  
  --Get user's screen size
  love.graphics.setMode(0,0,false,false,0)
  game.fullscreen.width = love.graphics.getWidth()
  game.fullscreen.height = love.graphics.getHeight()
  
  --Set game to windowed with all setting applied
  love.graphics.setMode(maxW*game.window.scale.x, maxH*game.window.scale.y, false, game.vysnc, game.aa)
  
end

--Toggle fullscreen for game
function game:toggleFullscreen()
  game.fullscreen.state = not game.fullscreen.state
  if game.fullscreen.state then
    love.graphics.setMode(game.fullscreen.width, game.fullscreen.height, true, game.vysnc, game.aa)
  else
    love.graphics.setMode(game.window.width, game.window.height, false, game.vysnc, game.aa)
  end
end

--Visual Stuff
--Colors = r,g,b,a
color = {}
color.black = {0,0,0,0}
color.white = { 255, 255, 255, 255 }

color.red = { 255,0,0,255 }
color.green = { 0, 255, 0, 255 }
color.blue = { 0, 0, 255, 255 }

color.yellow = { 255, 255, 0, 255 }
color.purple = { 255, 0, 255, 255 }
color.cyan = { 0, 255, 255, 255 }

color.orange = {255,128,0,255}

--Condense drawing an image and setting it's color to one line
function drawImage(i,c,x,y,r,sx,sy, ox, oy)
  love.graphics.setColor(c or {255,255,255,255})
  love.graphics.draw(i,x or 0,y or 0,r or 0, sx or 1, sy or 1, ox or 0, oy or 0)
end

--Math
math.pi2 = math.pi/2
math.pi3 = math.pi/3
math.pi4 = math.pi/4
math.pi6 = math.pi/6

-- Clamps a number to within a certain range.
function math.clamp(low, n, high)
  return math.min(math.max(n, low), high)
end
-- Returns the closest multiple of 'size'
function math.multiple(n, size)
  size = size
  return math.round(n/size)*size
end
-- Returns 'n' rounded to the nearest 'deci'th.
function math.round(n, deci)
  deci = 10^(deci or 0)
  return math.floor(n*deci+.5)/deci
end

-- Returns 1 if number is positive, -1 if it's negative, or 0 if it's 0.
function math.sign(n)
  return n>0 and 1 or n<0 and -1 or 0
  end

--Conversions
function math.toDegrees(n)
  return n*(180/math.pi)
end
function math.toRadians(n)
  return n*(math.pi/180)
end

-- Returns the angle between two points.
function math.angle(x1,y1, x2,y2)
  return math.atan2(x2-x1, y2-y1)
end

-- Returns the distance between two points.
function math.dist(x1,y1, x2,y2)
  return ((x2-x1)^2+(y2-y1)^2)^0.5
end